var IHG = {
	$break: {},
	URL_PATTERN: /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/i,
	IGNORE: {}
}

IHG.each = function (list, callback)
{
	var length = list.length;
	try {
		for(var i = 0; i < length; i++) {
			callback(list[i], i);
		}
	} catch(e) {
		if(e !== IHG.$break) {
			throw e;
		}
	}
}

IHG.emptyFunction = function () {}

IHG.blink = function (element)
{
	element.style.background = 'red';
	setTimeout(function() {
		element.style.background = '';
	}, 100);
}

IHG.$ = function(element)
{	
	if(element.addEventListener) {
		element.on = function(eventName, callback) {
			if(element['_event_' + eventName] !== undefined) {
				element.removeEventListener(eventName, element['_event_' + eventName], false);
			}
			
			var eventCallback = function(e) {
				if(callback(e) === false) {
					e.preventDefault();
				}
			}
			element['_event_' + eventName] = eventCallback;
			
			element.addEventListener(eventName, eventCallback, false);
		}
		
		element.fire = function(eventName)
		{
			return element['_event_' + eventName](null);
		}
	} else {
		element.on = function(eventName, callback) {
			element['on' + eventName] = function() {
				return callback(window.event);
			}
		}
		
		element.fire = function(eventName)
		{
			return element['on' + eventName]();
		}
	}
	
	return element;
}

IHG.clone = function(original) {
	var cloneObject = function(what)
	{
		for (var i in what) {
			if (typeof what[i] == 'object' && !(what[i] instanceof RegExp)) {
				this[i] = new cloneObject(what[i]);
			} else {
				this[i] = what[i];
			}
		}
	}
	return new cloneObject(original);
}

IHG.BadMethodCall = function(description)
{
	return new Error(description);
}

<? include 'ubbbar.user.IHG.Preferences.js' ?>